/*
 * Copyright (C) 2004, Velocityme Partnership
 * AnchorBean.java
 *
 * Created on 24 November 2004, 09:10
 */

package com.velocityme.entity;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import java.util.*;
import com.velocityme.interfaces.*;
import com.velocityme.valueobjects.AnchorValue;

/**
 *
 * @author  Robert
 * @ejb.bean
 *           type="CMP"
 *           cmp-version="2.x"
 *           name="Anchor"
 *           jndi-name="ejb/Anchor"
 *           view-type="local"
 * @ejb.transaction type="Required"
 *
 * @ejb.value-object match="*"
 *
 * @ejb.persistence table-name="anchor"
 *
 * @ejb.util generate="physical"
 *
 * @jboss.persistence create-table="true"
 *                    remove-table="false"
 */
public abstract class AnchorBean implements EntityBean {
    
    /**
    * Context set by container
    */
    private javax.ejb.EntityContext m_entityContext;

    public void setEntityContext(javax.ejb.EntityContext entityContext) {
        m_entityContext = entityContext;
    }

    public void unsetEntityContext() {
        m_entityContext = null;
    }
  
    /** @ejb.create-method */
    public com.velocityme.interfaces.AnchorPK ejbCreate(com.velocityme.interfaces.TaskLocal p_taskLocal,
                                                        com.velocityme.valueobjects.AnchorValue p_value) throws CreateException {
        setAnchorId(p_taskLocal.getTaskId());
        // EJB 2.0 spec says return null for CMP ejbCreate methods.
        return null;
    }

    public void ejbPostCreate(com.velocityme.interfaces.TaskLocal p_taskLocal,
                              com.velocityme.valueobjects.AnchorValue p_value) throws CreateException {
        // CMR relations must be set in ejbPostCreate
        setAnchorValue(p_value);
        setTaskLocal(p_taskLocal);
    }

    /**
     *  This gets a local object from a remote object.
     *  @ejb.interface-method view-type="remote"
     */
    public com.velocityme.interfaces.AnchorLocal getLocal() {
        return (AnchorLocal)m_entityContext.getEJBLocalObject();
    }
    
    /** @ejb.interface-method view-type="local" */
    public abstract com.velocityme.valueobjects.AnchorValue getAnchorValue();
    /** @ejb.interface-method view-type="local" */
    public abstract void setAnchorValue(com.velocityme.valueobjects.AnchorValue p_value);
    
    //=======================================================================
    //
    //                   ATTRIBUTES
    //
    //=======================================================================
      
    /**
     * @ejb.persistence column-name="anchorId"
     * @ejb.interface-method view-type="local"
     * @ejb.pk-field 
     */
    public abstract java.lang.Integer getAnchorId();
    /** @ejb.interface-method view-type="local" */
    public abstract void setAnchorId(java.lang.Integer anchorId);

    //=======================================================================
    //
    //                   RELATIONSHIPS
    //
    //=======================================================================
    
    /**
     * @ejb.interface-method view-type="local"
     * @ejb.relation name="Anchor-Task"
     *               role-name="Anchor-has-a-Task"
     * @jboss.relation fk-column="taskIdFk"
     *                 related-pk-field="taskId"
     * @ejb.value-object match="*" 
     *                   aggregate="com.velocityme.valueobjects.TaskValue"
     *                   aggregate-name="TaskValue"
     */
    public abstract com.velocityme.interfaces.TaskLocal getTaskLocal();
    /** @ejb.interface-method view-type="local" */
    public abstract void setTaskLocal(com.velocityme.interfaces.TaskLocal taskLocal);
    
   //=======================================================================
    //
    //                   MANAGEMENT METHODS
    //
    //=======================================================================
    
}
